<template>
  <div class="box-item">
    <div class="box-title">人车通行</div>
    <div class="box-body">
      <div class="box-body-title">人车通行变化趋势</div>
      <Echart id="leftCenter" v-if="pageflag" :options="options" class="left_center_inner" ref="charts" height="130px"
        width="280px" />
    </div>
  </div>
</template>

<script>
import { getPie3D, getParametricEquation } from '@/utils/chart'; //工具类js，页面路径自己修改
import { colorsA, colorsB, legend, xAxis, yAxis } from '@/config/EChartVar';

export default {
  name: 'DJtopleft',
  data() {
    return {
      options: {},
      countUserNumData: {
        axisData: ['10月', '11月', '12月', '1月', '2月'],
        seriesData0: [43000, 44409, 45806, 51801, 26043],
        seriesData1: [20123, 23325, 24285, 29225, 12290],
        seriesData2: [150, 110, 230, 310, 280],
      },
      pageflag: true,
      timer: null,
    };
  },
  created() {
    this.getData();
  },
  mounted() { },
  beforeDestroy() { },
  methods: {
    getData() {
      this.pageflag = true;

      this.$nextTick(() => {
        this.init(this.countUserNumData);
      });
    },
    init(currentData) {
      // let axisData = ["2021年", "2022年", "2023年", "2024年"];
      let axisData = currentData.axisData;
      let seriesData = [[...currentData.seriesData0], [...currentData.seriesData1]];

      const options = {
        // backgroundColor: "#0F224C", //背景色
        grid: {
          top: '17%',
          left: '4%',
          right: '8%',
          bottom: '3%',
          containLabel: true,
        },
        legend: {
          show: false,
          top: '0%',
          right: '4%',
          icon: 'circle',
          itemWidth: 12,
          itemHeight: 12,
          // itemGap: 60,
          textStyle: legend.textStyle,
          data: ['车', '人'],
        },
        xAxis: {
          type: 'category',
          data: axisData,
          // boundaryGap: false,
          boundaryGap: false,
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false, // 不显示下切线
          },
          axisLabel: xAxis.axisLabel,
          axisLine: {
            lineStyle: {
              background: 'rgba(176, 215, 255, 0.4)',
            },
          },
        },
        yAxis: [
          {
            type: 'value',
            // max: 1200,
            // min: 100,//
            // interval: 100,
            axisLabel: yAxis.axisLabel,
            axisLine: {
              show: false,
              // interval: 1,
              lineStyle: {
                color: 'rgba(0,0,0,0.5)',
              },
            },
            splitLine: {
              show: true,
              // interval: 1,
              lineStyle: {
                color: ['rgba(176, 215, 255, 0.2)'],
                width: 1,
                type: 'dashed',
              },
            },
            // splitLine: {
            //   show: false,
            // },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [],
      };
      const series = [
        {
          name: '车',
          type: 'line',
          // 动画配置
          animation: true,
          animationDuration: 2000,
          animationEasing: 'quarticInOut',
          animationDelay: function (idx) {
            return idx * 150;
          },
          // smooth: true,
          showSymbol: false,
          // symbol: 'circle',
          // symbolSize: 6,
          data: seriesData[0],
          itemStyle: {
            normal: {
              // color: "#38FFBA",
              color: 'rgba(0, 145, 255,0.8)',
            },
          },
          areaStyle: {
            color: colorsB[0],
          },
          lineStyle: {
            normal: {
              width: 2,
            },
          },
          label: {
            show: false,
            position: 'top',
            formatter: (par) => {
              return par.value + '';
            },
            textStyle: { fontSize: 12, color: '#FFF' },
          },
          markPoint: {
            symbol: 'circle',
            symbolSize: [14, 14], // 容器大小
            symbolOffset: ['0%', '0%'],
            data: [
              {
                name: '最大值',
                type: 'max',
                valueIndex: 1,
              },
            ],
            label: {
              show: true,
              position: 'top',
              fontSize: 12,
              color: '#FFF',
              formatter: (par) => {
                return par.value + '车次';
              },
            },
          },
        },
        {
          name: '人',
          type: 'line',
          // 动画配置
          animation: true,
          animationDuration: 2000,
          animationEasing: 'quarticInOut',
          animationDelay: function (idx) {
            return idx * 150;
          },
          // smooth: true,
          showSymbol: false,
          // symbol: 'circle',
          // symbolSize: 6,
          data: seriesData[1],
          itemStyle: {
            normal: {
              // color: "#38FFBA",
              color: 'rgba(0,219,254, .7)',
            },
          },
          areaStyle: {
            color: colorsB[1],
          },
          lineStyle: {
            normal: {
              width: 2,
            },
          },
          label: {
            show: false,
            position: 'top',
            formatter: (par) => {
              return par.value + '';
            },
            textStyle: { fontSize: 12, color: '#FFF' },
          },
          markPoint: {
            symbol: 'circle',
            symbolSize: [14, 14], // 容器大小
            symbolOffset: ['0%', '0%'],
            data: [
              {
                name: '最小值',
                type: 'min',
                valueIndex: 1,
              },
            ],
            label: {
              show: true,
              position: 'top',
              fontSize: 12,
              color: '#FFF',
              formatter: (par) => {
                return par.value + '人次';
              },
            },
          },
        },
      ];
      options.series = series;
      this.options = options;
    },
  },
};
</script>

<style lang="scss" scoped>
.box-item {
  width: 297px;
  height: 207px;
  background: url('../../../assets/img/launch/internet/homeBottombox.png') no-repeat center;
  background-position: center center;
  background-size: 100% 100%;
  margin-bottom: 25px;

  .box-title {
    position: relative;
    height: 55px;
    line-height: 55px;
    text-indent: 1em;
    font-size: 18px;
    font-weight: 600;

    &::after {
      position: absolute;
      top: -2px;
      content: url('../../../assets/img/launch/pack/pack_nav.png');
    }
  }

  .box-body {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    width: 100%;

    .box-body-title {
      position: relative;
      margin-top: -5px;
      // margin-left: 25px;
      height: 14px;
      line-height: 14px;
      width: calc(100% - 54px);
      // text-indent: 3em;
      padding-left: 22px;
      font-size: 10px;
      // background: linear-gradient(90deg, rgba(21, 77, 160, 0.2) 0%, rgba(21, 77, 160, 0) 100%), linear-gradient(270deg, rgba(21, 77, 160, 0) 0%, rgba(21, 132, 185, 0.44) 100%);
      background: url('../../../assets/img/launch/pack/header.png') no-repeat center;
      background-position: left center;
      background-size: contain;
    }
  }
}
</style>